﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Text;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace HML.Demo
{
    public partial class 首页Form : ItemFormTemplate
    {
        public 首页Form()
        {
            InitializeComponent();
        }

        #region 实现

        public override ItemFormTemplateViewObject AsynchRequestTask(ItemFormTemplateViewObject view)
        {
            System.Threading.Thread.Sleep(1000);
            view.ViewData = DemoHelper.GetDescription(AppDomain.CurrentDomain.BaseDirectory + "首页\\首页Form.rtf");
            return view;
        }

        public override void DataBind(ItemFormTemplateViewObject viewObject)
        {
            this.introduceBrowser.Rtf = viewObject.ViewData.ToString();
            this.timer.Tick += this.Timer_Tick;

            if (!this.timer.Enabled && this.ViewVisible)
            {
                this.timer.Start();
            }
        }

        public override void ShowView()
        {
            base.ShowView();

            if (!this.timer.Enabled && this.ViewStatus > ItemFormTemplateStatus.Create && this.ViewStatus < ItemFormTemplateStatus.Closed)
            {
                this.timer.Start();
            }
        }

        public override void HideView()
        {
            base.HideView();

            if (this.parentControl == null)
            {
                if (this.timer != null)
                {
                    this.timer.Stop();
                }
            }
        }

        public override void CloseView()
        {
            base.CloseView();
        }

        #endregion

        #region 属性面板

        private Control parentControl = null;

        private void Form_Load(object sender, EventArgs e)
        {
            this.open_buttonPlus.Click += this.Open_buttonPlus_Click;
            this.FormClosing += this.首页Form_FormClosing;
        }

        private void 首页Form_FormClosing(object sender, FormClosingEventArgs e)
        {
            this.FormBorderStyle = FormBorderStyle.None;
            this.TopLevel = false;
            this.parentControl.Controls.Add(this);
            this.parentControl = null;
            e.Cancel = true;
        }

        private void Open_buttonPlus_Click(object sender, EventArgs e)
        {
            if (this.Parent is TabPagePlus)
            {
                this.parentControl = this.Parent;
                this.FormBorderStyle = FormBorderStyle.Sizable;
                this.StartPosition = FormStartPosition.CenterScreen;
                this.Parent = null;
                this.TopLevel = true;

            }
            else
            {

                this.FormBorderStyle = FormBorderStyle.None;
                this.TopLevel = false;
                this.parentControl.Controls.Add(this);
                this.parentControl = null;
            }
        }

        private void Timer_Tick(object sender, EventArgs e)
        {
            this.maskCount_label.Text = MonitorManager.GetMaskingMaskingNativeWindowCount.ToString();
            this.maskTimerStatus_label.Text = MonitorManager.GetMaskingMaskingTimerEnabled.ToString();
            this.DropDownListPlusHookCount_label.Text = MonitorManager.GetDropDownListPlusHookCount.ToString();
            this.SkinPickerHookCount_label.Text = MonitorManager.GetSkinPickerHookCount.ToString();
            this.HitTesAnimationTimerStatus_label.Text = MonitorManager.GetAnimationTimerEnabled.ToString();
            this.HitTestAnimations_label.Text = MonitorManager.GetAnimationCount.ToString();
            this.HitTestNullAnimations_label.Text = MonitorManager.GetNullAnimationCount.ToString();

        }

        #endregion

        private void open_buttonPlus_Click_1(object sender, EventArgs e)
        {

        }
    }
}
